/*
 * @Description:
 * @version:
 * @Author: sunqian_sr
 * @Date: 2022-11-18 15:33:43
 * @LastEditors: Andy
 * @LastEditTime: 2022-12-15 19:46:39
 */
import { Cookies } from '@package/service'
import { defineStore } from '@/common/config/defineStore'
// import { defineStore } from 'pinia'
// useStore 可以是 useUser、useCart 之类的任何东西
// 第一个参数是应用程序中 store 的唯一 id
export default defineStore('settings', {
  state: () => ({
    appConfig: {
      // theme: '#409EFF',
      title: '供应商管理系统',
      fixedHeader: true,
      language: Cookies.get('language') || 'zh_CH',
      showLogo: true
    },
    sidebar: {
      opened: Cookies.get('sidebarStatus') ? Boolean(Cookies.get('sidebarStatus')) : true,
      withoutAnimation: false,
      hide: false
    }
  }),
  // 相当于 vue 中的 computed 计算属性 返回一个数值
  getters: {},
  actions: {
    setSidebarHide() {
      this.sidebar.opened = !this.sidebar.opened
      Cookies.set('sidebarStatus', this.sidebar.opened)
    },
    // setSiderbarOpend() {

    // },
    setLanguage(lan) {
      this.appConfig.language = lan || 'zh_CH'
      Cookies.set('language', this.settings.language)
    }
  }
})
